package opration;

import book.Book;
import book.BookList;

import java.util.Arrays;
import java.util.Scanner;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张宇田
 * Date: 2024-10-14
 * Time: 18:47
 */
public class SelBook implements IOprable{
    public void work(BookList bookList){
        System.out.println("查找图书");
        System.out.println("请输入你要查找的图书");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        BookList bookList1 = new BookList();
        int size = bookList1.getSize();
        for (int i =0 ;i<size;i++){
            /*遍历书架
            if(bookList1.books[i].name= name)
            访问不到 book 里面的name 就在 book类 里写get name方法
             */
            if(bookList1.books[i].getName().equals(name)){
                System.out.println("找到了");
                Book bookn = bookList1.selectBook(size);
                System.out.println(bookn);
                return;
            }
        }
        System.out.println("很遗憾，没有找到！");
    }
}
